﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using Entities;
using Utility;
using BUS;

public partial class Administrator_dathang_update : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        string madh = Request.QueryString["madh"].ToString();
        Tbl_DonHang_BUS.Update_DAGIAO(madh);

        Tbl_DonHang_Entities dh = Tbl_DonHang_BUS.GetByMADH(madh);
        Tbl_CTDH_Entities ctdh = Tbl_CTDH_BUS.GetByIDDH(dh.STT);
        Tbl_SanPham_Entities sp = Tbl_SanPham_BUS.GetByID(ctdh.SanPham);
        Tbl_Voucher_Entities vc = new Tbl_Voucher_Entities();
        vc.DonHang = dh.STT;
        string madh1 = dh.MaDH;
        string madh2 = madh1.Substring(3);
        vc.Serial = sp.STT.ToString() + madh2;
        vc.Used = false;
        Tbl_Voucher_BUS.Insert(vc);
        Response.Redirect(Session["trangadminhientai"].ToString());
    }
}
